package com.hejing.Map接口及其实现类的使用;

import java.util.*;

/**
 * ClassName: SingleTest
 * Package: com.hejing.Map接口及其实现类的使用
 * Description:
 *  添加你喜欢的歌手以及她唱过的一些你喜欢的歌曲并遍历
 * @Author: HeJing
 * @Create: 2023-05-20 19:43
 * @Version: 1.0
 */
public class SingerTest {
    public static void main(String[] args) {

        Map singers = new HashMap();

        String singer01 = "周杰伦";
        ArrayList songs01 = new ArrayList();
        songs01.add("夜曲");
        songs01.add("东风破");
        songs01.add("夜的第七章");
        songs01.add("稻香");
        singers.put(singer01, songs01);  // 添加了一个歌手和其歌曲

        String singer02 = "张学友";
        ArrayList songs02 = new ArrayList();
        songs02.add("遥远的她");
        songs02.add("我等到花儿也谢了");
        songs02.add("秋意浓");
        songs02.add("小城大事");
        singers.put(singer02, songs02);

        Set entrySet = singers.entrySet();
        Iterator iterator = entrySet.iterator();
        while(iterator.hasNext()) {
            Map.Entry entry = (Map.Entry) iterator.next();
            System.out.println("歌手: " + entry.getKey());
            System.out.println("歌曲有: " + entry.getValue());

        }

    }
}
























